//
//  QYEmotionView.swift
//  QingYuJSQ
//
//  Created by 李东 on 2024/4/5.
//

import UIKit

class QYEmotionView: UIView {

    @IBOutlet weak var imgView1: UIImageView!
    @IBOutlet weak var imgView2: UIImageView!
    @IBOutlet weak var imgView3: UIImageView!
    @IBOutlet weak var imgView4: UIImageView!
    @IBOutlet weak var imgView5: UIImageView!
    @IBOutlet weak var imgView6: UIImageView!
    @IBOutlet weak var imgView7: UIImageView!
    
    var selectCallBack:((Int) -> Void)?
    var contentView: UIView!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView = loadViewFromNib()
        contentView.frame = self.bounds
        addSubview(contentView)
        
        imgView1.tag = 10
        imgView2.tag = 11
        imgView3.tag = 12
        imgView4.tag = 13
        imgView5.tag = 14
        imgView6.tag = 15
        imgView7.tag = 16
        imgView1.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemClick(sender:))))
        imgView2.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemClick(sender:))))

        imgView3.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemClick(sender:))))

        imgView4.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemClick(sender:))))

        imgView5.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemClick(sender:))))

        imgView6.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemClick(sender:))))
        imgView7.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(itemClick(sender:))))


    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    @objc func itemClick(sender: UIGestureRecognizer) {
        guard let tempView = sender.view else { return  }
        selectCallBack?(tempView.tag - 10)
    }
    
}
